﻿<%@ Import Namespace="AspNetMvc.Entities" %>
<%@ Import Namespace="AspNetMvc.Models" %>
<%
    foreach (var description in Model.Properties.Keys)
    {
        if (description.IsNotAutomatic)
            continue;
%>
<p <% if (Model.ViewType == EventViewType.Search) { %> class="lo" <% } %>>
    <label>
        <%= description.Label %>:
    </label>
    <% if (Model.ViewType == EventViewType.Search)
       { %>
</p>
<p>
    <% } %>
    <% 
        if (!description.IsMultiValued)
        {
            Html.RenderPartial("EventsMarkup/DynamicProperties/EditableDynamicPropertyValue",
                               new ViewProperty(Model.ViewType, description.Uri.Fragment.Substring(1), Model.Properties[description][0], description));
        }
        else
        {
    %>
    <span>
        <%
            string firstRowId = null;
            string firstValueId = null;
            int index = 0;
            foreach (string value in Model.Properties[description])
            {
                string baseValue = String.Format("{0}_", description.Uri.Fragment.Substring(1));
                string valueId = String.Format("{0}{1}", baseValue, index);
        %>
        <span <% 
            if (index == 0) 
            {
                firstRowId = String.Format("{0}_FirstValueRow", valueId);
                firstValueId = valueId;
%> id="<%= firstRowId %>" <%
            }
%>>
            <%
                Html.RenderPartial("EventsMarkup/DynamicProperties/EditableDynamicPropertyValue",
                                   new ViewProperty(Model.ViewType, valueId, value, description)); %>
            <input type="button" value="+" onclick="AddPropertyValue('<%= baseValue %>',
                        '<%= firstRowId %>', '<%= firstValueId %>', '<%= description.IsHierarchy ? "false" : "true" %>')" />
            <br />
        </span>
        <%
index++;
            }
        %>
    </span>
    <%
        }
    %>
</p>
<%
    } 
%>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<AspNetMvc.Models.ViewPropertiesSet>" %>